package edu.ec.java02.group02.controller;

import edu.ec.java02.group02.domain.UserInfo;
import edu.ec.java02.group02.service.ProductService;
import edu.ec.java02.group02.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;


@Controller
@RequestMapping("/front")
public class FrontLoginController {

    @Autowired
    private UserService userService;
    @Autowired
    private ProductService productService;

    //示范
    @RequestMapping("/doLogin")
    public String doLogin(UserInfo userInfo,HttpServletRequest request){
        if(userService.login(userInfo)!=null) {
            request.getSession().setAttribute("login",userService.login(userInfo));
            return "redirect:/front/home";
        }else{
            return "/front/login";
        }

    }
}
